package com.iotp.service.knowledge;

import com.iotp.dao.knowledge.KnowledgeMapper;
import com.iotp.entity.knowledge.Knowledge;
import com.iotp.entity.knowledge.KnowledgeWithBLOBs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("knowledgeService")
public class KnowledgeServiceImpl implements KnowledgeService {
    @Autowired
    private KnowledgeMapper knowledgeMapper;
    @Override
    public Long add(KnowledgeWithBLOBs knowledgeWithBLOBs) {
        this.knowledgeMapper.insert(knowledgeWithBLOBs);
        return knowledgeWithBLOBs.getId();
    }

    @Override
    public void update(KnowledgeWithBLOBs knowledgeWithBLOBs) {
        this.knowledgeMapper.updateByPrimaryKeySelective(knowledgeWithBLOBs);
    }

    @Override
    public KnowledgeWithBLOBs queryById(Long id) {
        return this.knowledgeMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<KnowledgeWithBLOBs> queryList(KnowledgeWithBLOBs knowledgeWithBLOBs) {
        return this.knowledgeMapper.selectByCondition(knowledgeWithBLOBs);
    }

    @Override
    public List<Knowledge> queryByTypeId(Long kTypeId) {
        return this.knowledgeMapper.selectByTypeId(kTypeId);
    }

    @Override
    public void delete(Long id) {
        this.knowledgeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<KnowledgeWithBLOBs> querySc(List ids) {
        return this.knowledgeMapper.selectSc(ids);
    }
}
